#include <bits/stdc++.h>
using namespace std;
bool isOutStack(queue<int>& num_queue,stack<int>& pPop)
{
    bool flag = false;
    stack<int> tStack;
    while(pPop.size()>0)
    {
        int temp = pPop.top();
        pPop.pop();
        int queue_num = 0;
        if(tStack.size() == 0 && num_queue.size()>0)
        {
            do{
                queue_num = num_queue.front();
                num_queue.pop();
                tStack.push(queue_num);
            } while(queue_num != temp);
            tStack.pop();
        } else{
            while(tStack.size()>0)
            {
                if(tStack.top() != temp)
                {
                    if(num_queue.size()>0)
                    {
                        tStack.push(num_queue.front());
                        num_queue.pop();
                    }
                    else
                        return false;
                } else
                {
                    tStack.pop();
                    break;
                }
            }
        }
    }
    return true;

}
int main() {
    stack<int> b;
    queue<int> c;
    for(int i = 1;i<=5;i++)
        c.push(i);
    b.push(1);
    b.push(2);
    b.push(3);
    b.push(5);
    b.push(4);
    isOutStack(c,b)?cout<<"是的":cout<<"不是";
    return 0;
}